/*
 * Copyright 2008 Slava Chernyak
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License. 
 */
package com.chernyak.DataAdapter;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;

public final class Common {
	
	/** Create specified number of tabs
	 * 
	 * @param tab number of tabs
	 * @return tabs as String
	 */
	public static String tabGen(int tab) {
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < tab; i++) {
			sb.append("    ");
		}
		return sb.toString();
	}
	
	/** Write String contents to file
	 * 
	 * @param contents to write
	 * @param file to write to
	 */
	public static void writeFile(String contents, String file) {
		 try {
		        BufferedWriter out = new BufferedWriter(new FileWriter(file));
		        out.write(contents);
		        out.close();
	    } catch (IOException e) {
	    		System.err.println("Could not write file " + file);
	    		e.printStackTrace(System.err);
	    }
	}
}
